// import http from '@/utils/http'
import { asyncFormat } from '@/utils'

const rendom = () => parseInt(Math.random() * 100)

// 例子
// export const getOrderAllStatus = () => {
//     return http.post('/', {token: localStorage.getItem("token")}).then(res => res.data)
// }

// mock
export const getOrderAllStatus = () => Promise.resolve([
    {
        id: 'xxx',
        name: 'xxx'
    },
    {
        id: 'ccc',
        name: 'ccc'
    }
]) 

//mock
export const getInsureListList = () => Promise.resolve([
        {
            id: 'xxx',
            title: 'xxx'
        },
        {
            id: 'ccc',
            title: 'ccc'
        }
    ])


//mock
export const getCarTeamCompany = () => Promise.resolve([
    {
        id: 'xxx',
        title: 'xxx'
    },
    {
        id: 'ccc',
        title: 'ccc'
    }
])

//mock
export const getDriverList = () => Promise.resolve([
    {
        id: '1',
        title: 'tt'
    },
    {
        id: '2',
        title: `${rendom()}`
    }
])



export const loadOptionsWrap = function(prop, load){
    return async function(){
        const [res, err] = await asyncFormat(load())
        if(err){console.error(err); return}
        this[prop] = res
    }
}


// mock
export const getRescueHistoryList = param => {
    console.log(param)
    return Promise.resolve([
        {   
            id: 'oooo',
            status: 0,
            index: 0,
            publisher: 'xxx',
            balance_type: 0,
            abnormal_end: 1,
        },
        {   
            id: 'oooo',
            status: 120,
            index: 1,
            publisher: 'xxx',
            balance_type: 0,
            abnormal_end: 1,
        },
        {   
            id: 'oooo',
            status: 122,
            index: 2,
            publisher: 'xxx',
            balance_type: 0,
            abnormal_end: 1,
        }        
    ])
}



// mock
export const getFangKongList = param => {
    console.log('loading：', param)
    return Promise.resolve([
        {   
            order_id: 'oooo',
            status: 0,
            index: 0,
            driver_name: 'xxx',
            fleet_name: 0,
            ctime: new Date().getSeconds(),
            operating_pic: 'https://image.gcores.com/d3f25b4c-ce2b-40c1-aae6-652f8f1e6459.jpg?x-oss-process=image/resize,limit_1,m_lfit,w_2000,h_2000/quality,q_90|https://image.gcores.com/a1cb7c43-71dc-43ed-8a79-18122f60c9ca.jpeg?x-oss-process=image/resize,limit_1,m_lfit,w_1500,h_2000/quality,q_90/watermark,image_d2F0ZXJtYXJrLnBuZw,g_se,x_10,y_10|https://image.gcores.com/0734da3d-0760-4a49-a180-b7ee42326b5d.jpg?x-oss-process=image/quality,q_90/watermark,image_d2F0ZXJtYXJrLnBuZw,g_se,x_10,y_10',
        },
        {   
            order_id: 'oooo',
            status: 120,
            index: 1,
            driver_name: 'xxx',
            fleet_name: 0,
            ctime: new Date().getSeconds(),
            operating_pic: 'https://image.gcores.com/d3f25b4c-ce2b-40c1-aae6-652f8f1e6459.jpg?x-oss-process=image/resize,limit_1,m_lfit,w_2000,h_2000/quality,q_90|https://image.gcores.com/a1cb7c43-71dc-43ed-8a79-18122f60c9ca.jpeg?x-oss-process=image/resize,limit_1,m_lfit,w_1500,h_2000/quality,q_90/watermark,image_d2F0ZXJtYXJrLnBuZw,g_se,x_10,y_10|https://image.gcores.com/0734da3d-0760-4a49-a180-b7ee42326b5d.jpg?x-oss-process=image/quality,q_90/watermark,image_d2F0ZXJtYXJrLnBuZw,g_se,x_10,y_10',
        },
        {   
            order_id: 'oooo',
            status: 122,
            index: 2,
            driver_name: 'xxx',
            fleet_name: 0,
            ctime: new Date().getSeconds(),
            operating_pic: 'https://image.gcores.com/d3f25b4c-ce2b-40c1-aae6-652f8f1e6459.jpg?x-oss-process=image/resize,limit_1,m_lfit,w_2000,h_2000/quality,q_90|https://image.gcores.com/a1cb7c43-71dc-43ed-8a79-18122f60c9ca.jpeg?x-oss-process=image/resize,limit_1,m_lfit,w_1500,h_2000/quality,q_90/watermark,image_d2F0ZXJtYXJrLnBuZw,g_se,x_10,y_10|https://image.gcores.com/0734da3d-0760-4a49-a180-b7ee42326b5d.jpg?x-oss-process=image/quality,q_90/watermark,image_d2F0ZXJtYXJrLnBuZw,g_se,x_10,y_10',
        }        
    ])
}
